package com.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.constant.MessageConstant;
import com.entity.Result;
import com.service.OrderService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.Random;

@RequestMapping("/order")
@RestController
public class OrderController {
    //    http://localhost:88/order/findSetmealById.do?id=14
    @Reference
    private OrderService orderService;

    @RequestMapping("/findSetmealById")
    public Result findSetmealById(int id) {
        Result result = null;
        try {
            result = orderService.findSetmealById(id);
        } catch (Exception e) {
            e.printStackTrace();
            result = new Result(false, "查询失败");
        }
        return result;

    }

    /*提交预约*/
    @RequestMapping("/submitOrder")
    public Result submitOrder(@RequestBody Map map) {
        //传递后太做校验
        Result result = null;
        try {
            result = orderService.submitOrder(map);
        } catch (Exception e) {
            e.printStackTrace();
            result = new Result(false, "预约失败");
        }

        return result;
    }
    @RequestMapping("/findById")
    public Result findById(int id){
        //体检人,体检套餐,体检日期,预约类型
        Result result=null;
        try {
          result=orderService.findById(id);
        } catch (Exception e) {
            e.printStackTrace();
            result=new Result(false,"查询失败了");
        }
        return result;
    }

}
